package supermarketMIS.view;

import java.util.Scanner;

import supermarketMIS.bean.Admin;
import supermarketMIS.service.AdminService;

public class AdminUI {
	AdminService service=new AdminService();
	
	public void login() {
		//【1】输入
		String name;
		String password;
		Scanner in=new Scanner(System.in);
		System.out.println("请输入姓名：");
		name=in.next();
		System.out.println("请输入密码：");
		password=in.next();
		//【3】输出查找结果
		if(service.check(name, password)) {
			System.out.println("用户名和密码匹配，进入系统");
		}else {
			System.out.println("用户名和密码不匹配");
		}
	}
	public void addAdmin() {
		System.out.println("------添加管理员-------");
		//【1】输入
		String name;
		String password;
		Scanner in=new Scanner(System.in);
		System.out.println("请输入姓名：");
		name=in.next();
		System.out.println("请输入密码：");
		password=in.next();
		//封装管理员对象
		Admin admin=new Admin(name, password);
		//调用service进行添加，参数传递给service
		if(service.addAdmin(admin)==0) {
			System.out.println("添加管理员失败");
		}else {
			System.out.println("添加管理员成功");
		}
		 
		
	}

}
